import {userType} from "../models/user";
import myAxios from "../plugins/myAxios";
import {ResponseResult} from "../models/resopnse";
import {setCurrentUserState} from "../states/user.ts";

export const getCurrentUser = async () => {
    const res: ResponseResult<userType> = await myAxios.get('user/current');
    if (res.code === 0) {
        setCurrentUserState(res.data)
        console.log(res, '获取当前登录用户成功')
        return res.data;
    } else {
        console.log(res, '未登录')
    }
    return null;
}

